package com.sky.common.utils;

import java.util.Iterator;
import java.util.Map;

/**
 * map工具类
 */
public class MapUtil {

    /**
     * 同步
     *
     * @param source 源
     * @param target 目标
     */
    public static <K,V> void sync(Map<K,V> source, Map<K,V> target) {
        Iterator<Map.Entry<K,V>> iterator = source.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<K,V> entry = iterator.next();
            K key = entry.getKey();
            V value = entry.getValue();
            if (!target.containsKey(key)) {
                target.put(key, value);
            }
        }
    }

}
